package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.simple.ProjectTaskCommentSimple;
import com.nbsaas.boot.project.data.entity.ProjectTaskComment;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 任务评论-列表对象转换器
 */

public class ProjectTaskCommentSimpleConvert implements Converter<ProjectTaskCommentSimple, ProjectTaskComment> {


    @Override
    public ProjectTaskCommentSimple convert(ProjectTaskComment source) {
        ProjectTaskCommentSimple result = new ProjectTaskCommentSimple();

        result.setNote(source.getNote());

        try {
            if (source.getTask() != null) {
                result.setTask(source.getTask().getId());
            }
        } catch (Exception ignored) {
        }


        try {
            if (source.getTask() != null) {
                result.setTaskName(source.getTask().getName());
            }
        } catch (Exception ignored) {
        }

        if (source.getStoreState() != null) {
            result.setStoreStateName(String.valueOf(source.getStoreState()));
        }
        result.setStoreState(source.getStoreState());
        result.setId(source.getId());

        try {
            if (source.getUser() != null) {
                result.setUserName(source.getUser().getName());
            }
        } catch (Exception ignored) {
        }


        try {
            if (source.getUser() != null) {
                result.setUser(source.getUser().getId());
            }
        } catch (Exception ignored) {
        }

        result.setAddDate(source.getAddDate());
        result.setLastDate(source.getLastDate());


        return result;
    }

}